package com.itydl.bounce.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

/**
 * 作者：${Howard} on 2018/2/5 14:38
 *
 * @version 1.0
 *          说明：绘制圆形小球
 */
public class CircularView extends View {

    private int Color;
    private Paint mPaint;

    public void setColor(int color) {
        this.Color = color;
        mPaint.setColor(Color);
        invalidate();
    }

    public int getColor() {
        return Color;
    }

    public CircularView(Context context) {
        this(context,null);
    }

    public CircularView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public CircularView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mPaint = new Paint();
        mPaint.setAntiAlias(true);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        float cx = getWidth()/2;
        canvas.drawCircle(cx,cx,cx,mPaint);
    }

}
